home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: Correct Ansi C++ behavior?
- Date: 20 Apr 1996 14:44:01 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Sender: enno@kitz.inferenzsysteme.informatik.th-darmstadt.de
- Message-ID: <ltbukn83qm.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <3177C562.7578@ix.netcom.con>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: Robert Kleemann's message of Fri, 19 Apr 1996 09:54:58 -0700
- X-Newsreader: Gnus v5.1
-
- In article <3177C562.7578@ix.netcom.con> Robert Kleemann <goose@ix.netcom.con> writes:
-
- The following code compiles cleanly with MS VC v4.0 but I believe the last
- line should result in an error. Does anyone know for certain whether this is
- a bug or correct C++ behavior? I don't have any other compilers to test it
- on.
-
- thanx!
- Robert
-
- class Bar;
-
- class Foo
- {
- public:
- Foo();
- Foo(const Foo& p);
- private:
- // only Bar member functions and friends can
- // create a Foo object from a Bar object
- Foo(const Bar& p);
- };
-
- class Bar
- {
- public:
- Bar();
- Bar(const Bar& p);
- // any function can create a Bar object
- // from a Foo object
- Bar(const Foo& p);
- private:
- };
-
- void main()
- {
- Foo f;
- Bar b;
- Bar b2(f); // legal
- b = Bar(f); // legal
- //Foo f2(b); // should be illegal and is
- f = Foo(b); // I believe this should also be illegal but it isn't
- }
-
- The compiler should complain about both lines.
-
- Enno
-